package em.model;
public class ActionVO {
	private int CurrentAction;//当前指令
	private String PhotoData;//照片数据
	private String RealWorkData;//工况数据
	private String OtherData;//其他数据
	public String getOtherData() {
		return OtherData;
	}
	public void setOtherData(String otherData) {
		OtherData = otherData;
	}
	private int CurrStatus;//0:接受完成,1:发送或接收
	public int getCurrentAction() {
		return CurrentAction;
	}
	public void setCurrentAction(int currentAction) {
		CurrentAction = currentAction;
	}
	public String getPhotoData() {
		return PhotoData;
	}
	public void setPhotoData(String photoData) {
		PhotoData = photoData;
		new Thread(new DataEffCheck(60,8,photoData)).start();
	}
	public String getRealWorkData() {
		return RealWorkData;
	}
	public void setRealWorkData(String realWorkData) {
		RealWorkData = realWorkData;
		new Thread(new DataEffCheck(4,9,RealWorkData)).start();
	}
	public int getCurrStatus() {
		return CurrStatus;
	}
	public void setCurrStatus(int currStatus) {
		CurrStatus = currStatus;
	}
	
	
	public ActionVO(int currentAction, String photoData, String realWorkData,
			String otherData,int currStatus) {
		super();
		CurrentAction = currentAction;
		PhotoData = photoData;
		RealWorkData = realWorkData;
		OtherData = otherData;
		CurrStatus = currStatus;
	}
	@Override
	public String toString() {
		return "ActionVO [当前指令=" + CurrentAction + ", 照片数据="
				+ PhotoData + ", 实时工况=" + RealWorkData + ", 其他数据="
				+ OtherData + ", 当前状态=" + CurrStatus + "]";
	}
	public ActionVO() {
	}
	public String getActionData(int Action){
		switch (Action) {
			case 8 :
				return PhotoData;
			case 9:
				return RealWorkData;
			default :
				return OtherData;
		}
	}
	/*
	 * 数据检测线程:对照片数据和实时工况数据进行时间有效检测,有效时间过后数据为null
	 */
	class DataEffCheck implements Runnable{
		private int EffTime;
		private int Action;
		private String EffData;
		DataEffCheck(int EffTime,int Act,String EffData){
			this.EffTime=EffTime;
			this.Action=Act;
			this.EffData=EffData;
		}
		@Override
		public void run() {
			try {
				Thread.sleep(EffTime*1000);
				switch (Action) {
					case 8 :
						PhotoData=null;
						break;
					case 9 :
						if(EffData==RealWorkData){
							RealWorkData=null;
						}
						break;
					default :
						OtherData=null;
						break;
				}
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
		}
		
	}
}